import Vue from 'vue'
import VueRouter from "vue-router";
import Layout from '@/views/layout.vue'
import ArticleDetail from '@/views/article-detail.vue'
import Article from '@/views/article.vue'
import Collect from '@/views/collect.vue'
import Like from '@/views/like.vue'
import User from '@/views/user.vue'
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/',
      component: Layout,
      // 二级路由配置
      // 1. 配置规则(children)
      // 2. 在父亲组件上添加一个router-
      children: [
        {
          path: '/article',
          component: Article, 
        },
        {
          path: '/collect',
          component: Collect
        },
        {
          path: '/like',
          component: Like
        },
        {
          path: '/user',
          component: User
        },
      ]
    },
    {
      // 1.修改成动态路由
      path: '/detail/:id',
      component:ArticleDetail
    }
  ]
})

export default router